/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Plateau.java
 *
 * Created on 11 nov. 2011, 01:21:30
 */
package siam;

import java.awt.Color;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import jeuxEnConsole.PlateauCaracteres;

/**
 *
 * @author julien
 */
public class Plateau extends javax.swing.JPanel {

    private JButton[][] tabBouttons;
    private PlateauCaracteres plateauCaracteres;

    /** Creates new form Plateau */
    public Plateau() {
        initComponents();

        plateauCaracteres = new PlateauCaracteres();

        tabBouttons = new JButton[5][5];
        tabBouttons[0][0] = jB00;
        tabBouttons[0][1] = jB01;
        tabBouttons[0][2] = jB02;
        tabBouttons[0][3] = jB03;
        tabBouttons[0][4] = jB04;
        tabBouttons[1][0] = jB10;
        tabBouttons[1][1] = jB11;
        tabBouttons[1][2] = jB12;
        tabBouttons[1][3] = jB13;
        tabBouttons[1][4] = jB14;
        tabBouttons[2][0] = jB20;
        tabBouttons[2][1] = jB21;
        tabBouttons[2][2] = jB22;
        tabBouttons[2][3] = jB23;
        tabBouttons[2][4] = jB24;
        tabBouttons[3][0] = jB30;
        tabBouttons[3][1] = jB31;
        tabBouttons[3][2] = jB32;
        tabBouttons[3][3] = jB33;
        tabBouttons[3][4] = jB34;
        tabBouttons[4][0] = jB40;
        tabBouttons[4][1] = jB41;
        tabBouttons[4][2] = jB42;
        tabBouttons[4][3] = jB43;
        tabBouttons[4][4] = jB44;

        initEncadreGris();
        jBValiderCoup.setVisible(false);
        jBRetirerPlateau.setVisible(false);
        couSuivant.setVisible(false);
        cacherFleches();

        generePlateau();
    }

    public Plateau(PlateauCaracteres p) {
        initComponents();

        plateauCaracteres = p;

        tabBouttons = new JButton[5][5];
        tabBouttons[0][0] = jB00;
        tabBouttons[0][1] = jB01;
        tabBouttons[0][2] = jB02;
        tabBouttons[0][3] = jB03;
        tabBouttons[0][4] = jB04;
        tabBouttons[1][0] = jB10;
        tabBouttons[1][1] = jB11;
        tabBouttons[1][2] = jB12;
        tabBouttons[1][3] = jB13;
        tabBouttons[1][4] = jB14;
        tabBouttons[2][0] = jB20;
        tabBouttons[2][1] = jB21;
        tabBouttons[2][2] = jB22;
        tabBouttons[2][3] = jB23;
        tabBouttons[2][4] = jB24;
        tabBouttons[3][0] = jB30;
        tabBouttons[3][1] = jB31;
        tabBouttons[3][2] = jB32;
        tabBouttons[3][3] = jB33;
        tabBouttons[3][4] = jB34;
        tabBouttons[4][0] = jB40;
        tabBouttons[4][1] = jB41;
        tabBouttons[4][2] = jB42;
        tabBouttons[4][3] = jB43;
        tabBouttons[4][4] = jB44;

        initEncadreGris();
        jBValiderCoup.setVisible(false);
        jBRetirerPlateau.setVisible(false);
        couSuivant.setVisible(false);
        cacherFleches();

        generePlateau();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jB13 = new javax.swing.JButton();
        jB12 = new javax.swing.JButton();
        jB11 = new javax.swing.JButton();
        jB21 = new javax.swing.JButton();
        jB22 = new javax.swing.JButton();
        jB14 = new javax.swing.JButton();
        jB20 = new javax.swing.JButton();
        jB30 = new javax.swing.JButton();
        jB31 = new javax.swing.JButton();
        jB23 = new javax.swing.JButton();
        jB24 = new javax.swing.JButton();
        jB44 = new javax.swing.JButton();
        jB43 = new javax.swing.JButton();
        jB42 = new javax.swing.JButton();
        jB41 = new javax.swing.JButton();
        jB40 = new javax.swing.JButton();
        jB34 = new javax.swing.JButton();
        jB00 = new javax.swing.JButton();
        jB01 = new javax.swing.JButton();
        jB02 = new javax.swing.JButton();
        jB03 = new javax.swing.JButton();
        jB32 = new javax.swing.JButton();
        jB04 = new javax.swing.JButton();
        jB33 = new javax.swing.JButton();
        jB10 = new javax.swing.JButton();
        reserveJoueur2 = new javax.swing.JButton();
        reserveJoueur1 = new javax.swing.JButton();
        nbReserve2 = new javax.swing.JLabel();
        nbReserve1 = new javax.swing.JLabel();
        couSuivant = new javax.swing.JButton();
        HGS = new javax.swing.JButton();
        HGE = new javax.swing.JButton();
        BGN = new javax.swing.JButton();
        BGE = new javax.swing.JButton();
        BDN = new javax.swing.JButton();
        HDS = new javax.swing.JButton();
        HDO = new javax.swing.JButton();
        BDO = new javax.swing.JButton();
        jBValiderCoup = new javax.swing.JButton();
        jBRetirerPlateau = new javax.swing.JButton();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(siam.SiamApp.class).getContext().getResourceMap(Plateau.class);
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setName("Form"); // NOI18N

        jB13.setName("jB13"); // NOI18N

        jB12.setName("jB12"); // NOI18N

        jB11.setName("jB11"); // NOI18N

        jB21.setName("jB21"); // NOI18N

        jB22.setName("jB22"); // NOI18N

        jB14.setName("jB14"); // NOI18N

        jB20.setName("jB20"); // NOI18N

        jB30.setName("jB30"); // NOI18N

        jB31.setName("jB31"); // NOI18N

        jB23.setName("jB23"); // NOI18N

        jB24.setName("jB24"); // NOI18N

        jB44.setName("jB44"); // NOI18N

        jB43.setName("jB43"); // NOI18N

        jB42.setName("jB42"); // NOI18N

        jB41.setName("jB41"); // NOI18N

        jB40.setName("jB40"); // NOI18N

        jB34.setName("jB34"); // NOI18N

        jB00.setName("jB00"); // NOI18N

        jB01.setName("jB01"); // NOI18N

        jB02.setName("jB02"); // NOI18N

        jB03.setName("jB03"); // NOI18N

        jB32.setName("jB32"); // NOI18N

        jB04.setName("jB04"); // NOI18N

        jB33.setName("jB33"); // NOI18N

        jB10.setName("jB10"); // NOI18N

        reserveJoueur2.setIcon(resourceMap.getIcon("reserveJoueur2.icon")); // NOI18N
        reserveJoueur2.setText(resourceMap.getString("reserveJoueur2.text")); // NOI18N
        reserveJoueur2.setToolTipText(resourceMap.getString("reserveJoueur2.toolTipText")); // NOI18N
        reserveJoueur2.setContentAreaFilled(false);
        reserveJoueur2.setName("reserveJoueur2"); // NOI18N

        reserveJoueur1.setIcon(resourceMap.getIcon("reserveJoueur1.icon")); // NOI18N
        reserveJoueur1.setText(resourceMap.getString("reserveJoueur1.text")); // NOI18N
        reserveJoueur1.setToolTipText(resourceMap.getString("reserveJoueur1.toolTipText")); // NOI18N
        reserveJoueur1.setContentAreaFilled(false);
        reserveJoueur1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        reserveJoueur1.setName("reserveJoueur1"); // NOI18N

        nbReserve2.setText(resourceMap.getString("nbReserve2.text")); // NOI18N
        nbReserve2.setName("nbReserve2"); // NOI18N

        nbReserve1.setText(resourceMap.getString("nbReserve1.text")); // NOI18N
        nbReserve1.setName("nbReserve1"); // NOI18N

        couSuivant.setBackground(resourceMap.getColor("couSuivant.background")); // NOI18N
        couSuivant.setFont(resourceMap.getFont("couSuivant.font")); // NOI18N
        couSuivant.setText(resourceMap.getString("couSuivant.text")); // NOI18N
        couSuivant.setToolTipText(resourceMap.getString("couSuivant.toolTipText")); // NOI18N
        couSuivant.setName("couSuivant"); // NOI18N

        HGS.setIcon(resourceMap.getIcon("HGS.icon")); // NOI18N
        HGS.setText(resourceMap.getString("HGS.text")); // NOI18N
        HGS.setToolTipText(resourceMap.getString("HGS.toolTipText")); // NOI18N
        HGS.setContentAreaFilled(false);
        HGS.setName("HGS"); // NOI18N

        HGE.setIcon(resourceMap.getIcon("HGE.icon")); // NOI18N
        HGE.setText(resourceMap.getString("HGE.text")); // NOI18N
        HGE.setToolTipText(resourceMap.getString("HGE.toolTipText")); // NOI18N
        HGE.setContentAreaFilled(false);
        HGE.setName("HGE"); // NOI18N

        BGN.setIcon(resourceMap.getIcon("BGN.icon")); // NOI18N
        BGN.setText(resourceMap.getString("BGN.text")); // NOI18N
        BGN.setToolTipText(resourceMap.getString("BGN.toolTipText")); // NOI18N
        BGN.setContentAreaFilled(false);
        BGN.setName("BGN"); // NOI18N

        BGE.setIcon(resourceMap.getIcon("BGE.icon")); // NOI18N
        BGE.setText(resourceMap.getString("BGE.text")); // NOI18N
        BGE.setToolTipText(resourceMap.getString("BGE.toolTipText")); // NOI18N
        BGE.setContentAreaFilled(false);
        BGE.setName("BGE"); // NOI18N

        BDN.setIcon(resourceMap.getIcon("BDN.icon")); // NOI18N
        BDN.setText(resourceMap.getString("BDN.text")); // NOI18N
        BDN.setToolTipText(resourceMap.getString("BDN.toolTipText")); // NOI18N
        BDN.setContentAreaFilled(false);
        BDN.setName("BDN"); // NOI18N

        HDS.setIcon(resourceMap.getIcon("HDS.icon")); // NOI18N
        HDS.setText(resourceMap.getString("HDS.text")); // NOI18N
        HDS.setToolTipText(resourceMap.getString("HDS.toolTipText")); // NOI18N
        HDS.setContentAreaFilled(false);
        HDS.setName("HDS"); // NOI18N

        HDO.setIcon(resourceMap.getIcon("HDO.icon")); // NOI18N
        HDO.setText(resourceMap.getString("HDO.text")); // NOI18N
        HDO.setToolTipText(resourceMap.getString("HDO.toolTipText")); // NOI18N
        HDO.setContentAreaFilled(false);
        HDO.setName("HDO"); // NOI18N

        BDO.setIcon(resourceMap.getIcon("BDO.icon")); // NOI18N
        BDO.setText(resourceMap.getString("BDO.text")); // NOI18N
        BDO.setToolTipText(resourceMap.getString("BDO.toolTipText")); // NOI18N
        BDO.setContentAreaFilled(false);
        BDO.setName("BDO"); // NOI18N

        jBValiderCoup.setBackground(resourceMap.getColor("jBValiderCoup.background")); // NOI18N
        jBValiderCoup.setFont(resourceMap.getFont("jBValiderCoup.font")); // NOI18N
        jBValiderCoup.setText(resourceMap.getString("jBValiderCoup.text")); // NOI18N
        jBValiderCoup.setToolTipText(resourceMap.getString("jBValiderCoup.toolTipText")); // NOI18N
        jBValiderCoup.setName("jBValiderCoup"); // NOI18N

        jBRetirerPlateau.setBackground(resourceMap.getColor("jBRetirerPlateau.background")); // NOI18N
        jBRetirerPlateau.setFont(resourceMap.getFont("jBRetirerPlateau.font")); // NOI18N
        jBRetirerPlateau.setText(resourceMap.getString("jBRetirerPlateau.text")); // NOI18N
        jBRetirerPlateau.setToolTipText(resourceMap.getString("jBRetirerPlateau.toolTipText")); // NOI18N
        jBRetirerPlateau.setName("jBRetirerPlateau"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(185, 185, 185)
                        .addComponent(HGS, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(277, 277, 277)
                        .addComponent(HDS, 0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(reserveJoueur2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(reserveJoueur1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(22, 22, 22)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(BGE, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(HGE, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(45, 45, 45)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(nbReserve1)
                                    .addComponent(nbReserve2)))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jBValiderCoup, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jBRetirerPlateau, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jB30, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB31, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB32, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB33, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB34, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jB20, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB21, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB22, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB23, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jB24, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(jB40, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jB41, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jB42, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jB43, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(18, 18, 18)
                                            .addComponent(BGN, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jB44, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(BDN, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(12, 12, 12)))))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jB10, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB11, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB12, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB13, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB14, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jB00, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB01, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB02, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB03, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jB04, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(HDO, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(couSuivant, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BDO, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(HGS, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(HDS, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jB04, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB03, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB02, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB01, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB00, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jB14, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB13, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB12, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB11, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jB10, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(reserveJoueur2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(nbReserve2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jBValiderCoup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(HDO, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(80, 80, 80)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(104, 104, 104)
                                        .addComponent(BGE, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(72, 72, 72)
                                        .addComponent(nbReserve1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(reserveJoueur1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jB24, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB23, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB22, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB20, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB21, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jB34, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB33, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB32, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB31, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jB30, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jBRetirerPlateau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(couSuivant, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(BDO, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jB43, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                    .addComponent(jB42, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                    .addComponent(jB41, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                    .addComponent(jB40, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                    .addComponent(jB44, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(BDN, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(BGN, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(HGE, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(42, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    public JButton getjBRetirerPlateau() {
        return jBRetirerPlateau;
    }

    public JButton getjBValiderCoup() {
        return jBValiderCoup;
    }

    public JButton getBDN() {
        return BDN;
    }

    public JButton getBGE() {
        return BGE;
    }

    public JButton getBGN() {
        return BGN;
    }

    public JButton getHDO() {
        return HDO;
    }

    public JButton getHDS() {
        return HDS;
    }

    public JButton getHGE() {
        return HGE;
    }

    public JButton getHGS() {
        return HGS;
    }

    public JButton getBDO() {
        return BDO;
    }

    public JButton getCoupSuivant() {
        return this.couSuivant;
    }

    public JButton getReserveJoueur1() {
        return reserveJoueur1;
    }

    public JButton getReserveJoueur2() {
        return reserveJoueur2;
    }

    public JButton[][] getTabBouttons() {
        return tabBouttons;
    }

    public PlateauCaracteres getPlateauCaracteres() {
        return plateauCaracteres;
    }

    public ArrayList<JButton> getAllBoutton() {
        ArrayList<JButton> allBoutton = new ArrayList<JButton>();
        allBoutton.add(reserveJoueur1);
        allBoutton.add(reserveJoueur2);
        allBoutton.add(jB00);
        allBoutton.add(jB01);
        allBoutton.add(jB02);
        allBoutton.add(jB03);
        allBoutton.add(jB04);
        allBoutton.add(jB10);
        allBoutton.add(jB11);
        allBoutton.add(jB12);
        allBoutton.add(jB13);
        allBoutton.add(jB14);
        allBoutton.add(jB20);
        allBoutton.add(jB21);
        allBoutton.add(jB22);
        allBoutton.add(jB23);
        allBoutton.add(jB24);
        allBoutton.add(jB30);
        allBoutton.add(jB31);
        allBoutton.add(jB32);
        allBoutton.add(jB33);
        allBoutton.add(jB34);
        allBoutton.add(jB40);
        allBoutton.add(jB41);
        allBoutton.add(jB42);
        allBoutton.add(jB43);
        allBoutton.add(jB44);

        return allBoutton;
    }

    public void initEncadreGris() {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                tabBouttons[i][j].setBorder(BorderFactory.createLineBorder(new Color(242, 242, 242)));
            }
        }
        reserveJoueur1.setBorder(BorderFactory.createLineBorder(new Color(242, 242, 242)));
        reserveJoueur2.setBorder(BorderFactory.createLineBorder(new Color(242, 242, 242)));
    }

    public void cacherFleches() {
        BDN.setVisible(false);
        BDO.setVisible(false);
        BGE.setVisible(false);
        BGN.setVisible(false);
        HDO.setVisible(false);
        HDS.setVisible(false);
        HGE.setVisible(false);
        HGS.setVisible(false);
    }

    public int getReserveRino() {
        int reserveRino = 5;

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (plateauCaracteres.getPiece(i, j) == 'n' || plateauCaracteres.getPiece(i, j) == 's' || plateauCaracteres.getPiece(i, j) == 'e' || plateauCaracteres.getPiece(i, j) == 'o') {
                    reserveRino--;
                }
            }
        }
        return reserveRino;
    }

    public int getReserveElephant() {
        int reserveElephant = 5;

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (plateauCaracteres.getPiece(i, j) == 'N' || plateauCaracteres.getPiece(i, j) == 'S' || plateauCaracteres.getPiece(i, j) == 'E' || plateauCaracteres.getPiece(i, j) == 'O') {
                    reserveElephant--;
                }
            }
        }
        return reserveElephant;
    }

    /**
     * Construit le nouveau plateau à partir d'un tableau de caractères
     * @param tabCarateres un tableaux de caractères
     */
    public void generePlateau() {

        this.nbReserve1.setText("X" + getReserveElephant());
        this.nbReserve2.setText("X" + getReserveRino());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(siam.SiamApp.class).getContext().getResourceMap(Plateau.class);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {

                switch (plateauCaracteres.getPiece(i, j)) {
                    //switch (tabCaracteres[i][j]) {
                    case 'M':
                        //System.out.println("la case [" + i + "][" + j + "] est une montagne !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("montagne"));
                        break;
                    case 'N':
                        //System.out.println("la case [" + i + "][" + j + "] est un elephant oriente Nord !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("elephant.nord"));
                        break;
                    case 'E':
                        //System.out.println("la case [" + i + "][" + j + "] est un elephant oriente Est !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("elephant.est"));
                        break;
                    case 'S':
                        //System.out.println("la case [" + i + "][" + j + "] est un elephant oriente Sud !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("elephant.sud"));
                        break;
                    case 'O':
                        //System.out.println("la case [" + i + "][" + j + "] est un elephant oriente Ouest !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("elephant.ouest"));
                        break;
                    case 'n':
                        //System.out.println("la case [" + i + "][" + j + "] est un rino oriente Nord !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("rino.nord"));
                        break;
                    case 'e':
                        //System.out.println("la case [" + i + "][" + j + "] est un rino oriente Est !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("rino.est"));
                        break;
                    case 's':
                        //System.out.println("la case [" + i + "][" + j + "] est un rino oriente Sud !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("rino.sud"));
                        break;
                    case 'o':
                        //System.out.println("la case [" + i + "][" + j + "] est un rino oriente Ouest !!");
                        tabBouttons[i][j].setIcon(resourceMap.getIcon("rino.ouest"));
                        break;
                    default:
                        //System.out.println("Case vide !!");
                        tabBouttons[i][j].setIcon(null);
                        break;
                }
            }
        }

    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BDN;
    private javax.swing.JButton BDO;
    private javax.swing.JButton BGE;
    private javax.swing.JButton BGN;
    private javax.swing.JButton HDO;
    private javax.swing.JButton HDS;
    private javax.swing.JButton HGE;
    private javax.swing.JButton HGS;
    private javax.swing.JButton couSuivant;
    private javax.swing.JButton jB00;
    private javax.swing.JButton jB01;
    private javax.swing.JButton jB02;
    private javax.swing.JButton jB03;
    private javax.swing.JButton jB04;
    private javax.swing.JButton jB10;
    private javax.swing.JButton jB11;
    private javax.swing.JButton jB12;
    private javax.swing.JButton jB13;
    private javax.swing.JButton jB14;
    private javax.swing.JButton jB20;
    private javax.swing.JButton jB21;
    private javax.swing.JButton jB22;
    private javax.swing.JButton jB23;
    private javax.swing.JButton jB24;
    private javax.swing.JButton jB30;
    private javax.swing.JButton jB31;
    private javax.swing.JButton jB32;
    private javax.swing.JButton jB33;
    private javax.swing.JButton jB34;
    private javax.swing.JButton jB40;
    private javax.swing.JButton jB41;
    private javax.swing.JButton jB42;
    private javax.swing.JButton jB43;
    private javax.swing.JButton jB44;
    private javax.swing.JButton jBRetirerPlateau;
    private javax.swing.JButton jBValiderCoup;
    private javax.swing.JLabel nbReserve1;
    private javax.swing.JLabel nbReserve2;
    private javax.swing.JButton reserveJoueur1;
    private javax.swing.JButton reserveJoueur2;
    // End of variables declaration//GEN-END:variables
}
